import Vue from 'vue';
import Vuex from 'vuex';
import {getUserMsg} from '../api/systemManage/user';

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    headerMenu: [],
    departmentIdList: [],
    menuList: [],
    userInfo: {}
  },
  getters: {

  },
  mutations: {
    // 更改用户信息
    changeUserInfo(state, payload) {
      state.userInfo = payload;
      // console.log(state.userInfo);
    }
  },
  actions: {
    // 获取用户信息
    async getUserInfoAsync(context, payload) {
      const res = await getUserMsg(payload);
      // console.log(res);
      context.commit('changeUserInfo', res.data);
      // return res;
    }
  },
  modules: {
  }
});

export default store;
